package com.bjwl.service.impl;

import com.bjwl.dao.DbackupMapper;
import com.bjwl.pojo.Dbackup;
import com.bjwl.service.DbackupService;
import com.bjwl.utils.MysqlDataBaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author: dzx
 * @Date:Create：in 2020/4/18 8:50
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class DbackupServiceImpl implements DbackupService {

    @Autowired
    private DbackupMapper dbackupMapper;

    @Override
    public void addDbackup(String format) throws InterruptedException {
        if (MysqlDataBaseUtil.exportDatabaseTool("118.190.202.77", "homemaking", "homemaking", "/usr/local/sql", format+".sql", "homemaking")) {
            System.out.println("数据库成功备份！！！");
        } else {
            System.out.println("数据库备份失败！！！");
        }
    }

    @Override
    public List<Dbackup> findAllDbackup() {
        return dbackupMapper.findAllDbackup();
    }
}
